<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ taglib prefix="his_fns" uri="/WEB-INF/tlds/his_fns.tld" %>
<script type="text/javascript">
    function page(n,s){
        $("#pageNo").val(n);
        $("#pageSize").val(s);
        $("#searchForm").submit();
        return false;
    }
</script>
<div class="content-wrap">
    <div class="wrapper" style="bottom: 50px;">
        <ul class="nav nav-tabs">
            <li class="active">
                <a href="#"   onclick="loadDiv('mainCenterDiv','${ctx}/csm/expDetails/importQue')">入库记录列表</a>
            </li>
        </ul>
        <section class="panel panel-default">
            <div class="panel-body">
                <div class="table-responsive no-border">
                    <div class="datatable-top">
                        <div class="pull-left">
                            <form:form id="searchForm" modelAttribute="expImportDetail"  onsubmit="return loadDivForm('mainCenterDiv','searchForm','${ctx}/csm/expDetails/importQue');" method="post" class="form-inline">
                                <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
                                <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
                                <div class="form-group">
                                    <label>消耗品名称:&nbsp;&nbsp;</label>
                                    <form:input path="expDict.expName" id="expName" maxlength="50" class="form-control"></form:input>
                                </div>
                                <div class="form-group">
                                <label class=" control-label">日期区间：</label>
                                <input name="startDate" id="startDate" htmlEscape="false" readonly class="form-control Wdate" data-parsley-required="true" readonly
                                       onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
                                <label class=" control-label">至</label>
                                <input name="stopDate" id="stopDate" htmlEscape="false" readonly class="form-control Wdate" data-parsley-required="true" readonly
                                       onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
                            </div>
                                <input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
                                <input id="btnPrint" class="btn btn-primary" type="submit" value="打印单据" />
                            </form:form>
                        </div>
                    </div>
                    <table id="contentTable" class="table table-bordered table-striped mg-t datatable">
                        <thead>
                        <tr>
                            <th>品名</th>
                            <th>型号</th>
                            <th hidden>包装数量</th>
                            <th>规格</th>
                            <th>单位</th>
                            <th>生产厂家</th>
                            <th>批号</th>
                            <th>有效期</th>
                            <th>灭菌方式</th>
                            <th>灭菌批号</th>
                            <th>灭菌日期</th>
                            <th>入库单价</th>
                            <%--<th>折扣</th>--%>
                            <th>入库数量</th>
                            <th>入库单号</th>
                            <th>入库类别</th>
                            <th>入库日期</th>
                            <th>供货方</th>

                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${page.list}" var="expImportDetail">
                        <tr>
                            <td> ${expImportDetail.expDict.expName}</td>
                            <td> ${expImportDetail.expDict.expModel}</td>
                            <td hidden> ${expImportDetail.packageNum}</td>
                            <td> ${expImportDetail.packageSpec}</td>
                            <td> ${fns:getDictLabels(expImportDetail.packageUnits, 'SPEC_UNIT', '')}</td>
                            <td> ${his_fns:getExpSupplierById(expImportDetail.expInfo.expSupplierCata.id)}</td>
                            <td> ${expImportDetail.batchNo}</td>
                            <td><fmt:formatDate value="${expImportDetail.expireDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                            <td>${fns:getDictLabels(expImportDetail.sterilizationMethod, 'STERILIZATION_METHOD', '')}</td>
                            <td>${expImportDetail.sterilizationBatchNo}</td>
                            <td><fmt:formatDate value="${expImportDetail.sterilizationDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                            <td> ${expImportDetail.purchasePrice}</td>
                            <%--<td> ${expImportDetail.discount}</td>--%>
                            <td> ${expImportDetail.quantity}</td>
                            <c:set var="expImportMaster" value="${his_fns:getExpMasterDetilByMasterId(expImportDetail.masterId)}"> </c:set>
                            <td> ${expImportMaster.documentNo}</td>
                            <td> ${expImportMaster.importClass}</td>
                            <td> <fmt:formatDate value="${expImportMaster.importDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                           <%-- <td> ${expImportMaster.supplier}</td>--%>
                            <c:choose>
                            <c:when test="${!empty expImportMaster.supplier}">
                                <td> ${his_fns:getExpSupplierById(expImportMaster.supplier)}</td>
                            </c:when>
                            <c:when test="${!empty expImportMaster.storageFrom}">
                                <td> ${his_fns:getExpDeptById(expImportMaster.storageFrom)}</td>
                            </c:when>
                                <c:otherwise>
                                    <td></td>
                                </c:otherwise>
                            </c:choose>
                          </tr>
                          </c:forEach>

                    </table>
                    <div class="pagination">${page}</div>
                </div>
            </div>
        </section>
    </div>
</div>
                   </table>
                      <div class="pagination">${page}</div>
                  </div>
              </div>
          </section>
      </div>
  </div>
<script>
    //设置出库日期为当前时间,不能编辑
    var date = new Date();
    var nowMonth = "";
    if(date.getMonth()+1 <= 9){
        nowMonth = "0" + (date.getMonth() + 1) + "";
    }else{
        nowMonth = (date.getMonth() + 1) + "";
    }
    var hours = "";
    if(date.getHours() < 10){
        hours = "0" + date.getHours();
    }else{
        hours = date.getHours();
    }
    var minutes = "";
    if(date.getMinutes() < 10){
        minutes = "0" + date.getMinutes();
    }else{
        minutes = date.getMinutes();
    }
    var seconds = "";
    if(date.getSeconds() < 10){
        seconds = "0" + date.getSeconds();
    }else{
        seconds = date.getSeconds();
    }
    var startDate = date.getFullYear() + "-" + nowMonth + "-" + date.getDate() + " 00:00:00";
    var stopDate = date.getFullYear() + "-" + nowMonth + "-" + date.getDate() + " 23:59:59";
    $('#startDate').val(startDate);
    $('#stopDate').val(stopDate);

    $(function(){
        $("#btnPrint").click(function(){
            var expName=$("#expName").val();
            var startDate=$("#startDate").val();
            var stopDate=$("#stopDate").val();
            var remarks='1';
            printPdf('${ctx}/csm/expDetails/expImportDetailsPrint?expName='+expName+'&updateDateStr='+startDate+'&createDateStr'+stopDate+'&remarks='+remarks);
        })
    })
</script>